package com.example.mylearn.proxy.dynamicProxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyInvocationHandler implements InvocationHandler {

    private final Object target;

    public MyInvocationHandler(Object target)
    {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("beforeMethod" + method.getName());
        final Object invoke = method.invoke(target, args);
        System.out.println("afterMethod" + method.getName());
        return invoke;
    }
}
